from configobj import ConfigObj
from datetime import datetime, timedelta
from loguru import logger as log

config = ConfigObj("cache", encoding='UTF-8')

# config.write()
print(config)

try:
    if datetime.now() > datetime.fromtimestamp(int(config['DB']['time'])):
        print(config['DB']['access_token'])
except KeyError:
    log.info("初始化缓存")

at = "测试"
config['DB'] = {'time': int((datetime.now() + timedelta(seconds=7200)).timestamp()), 'access_token': at}
config.write()



